<!DOCTYPE html>
<html>
<head><meta charset="utf-8" />
<title>302-内建函数</title>

<script src="/lib/require/index.js"></script>
<script src="/lib/jquery/index.js"></script>

<!-- 改为引入外部样式 -->
<link rel="stylesheet" href="/css/custom.css">

<!-- Loading mathjax macro -->
<!-- Load mathjax -->
    <script src="/lib/mathjax/index.js"></script>
    <!-- MathJax configuration -->
    <script type="text/x-mathjax-config">
    MathJax.Hub.Config({
        tex2jax: {
            inlineMath: [ ['$','$'], ["\\(","\\)"] ],
            displayMath: [ ['$$','$$'], ["\\[","\\]"] ],
            processEscapes: true,
            processEnvironments: true
        },
        // Center justify equations in code and markdown cells. Elsewhere
        // we use CSS to left justify single line equations in code cells.
        displayAlign: 'center',
        "HTML-CSS": {
            styles: {'.MathJax_Display': {"margin": 0}},
            linebreaks: { automatic: true }
        }
    });
    </script>
    <!-- End of mathjax configuration --></head>
<body>
<div class="toc">
<ul>
                        
                        
                        <li class="toc-li-2">
                            <a href="#built-in-function">built-in function</a>
                        </li>
                    
                
            
                        
                        
                        <li class="toc-li-3">
                            <a href="#常用内建函数">常用内建函数</a>
                        </li>
                    
                
            
            
            
                        
                        
                        <li class="toc-li-3">
                            <a href="#数学相关">数学相关</a>
                        </li>
                    
                
            
            
            
                        
                        
                        <li class="toc-li-3">
                            <a href="#数据类型">数据类型</a>
                        </li>
                    
                
            
            
            
                        
                        
                        <li class="toc-li-3">
                            <a href="#函数式编程">函数式编程</a>
                        </li>
                    
                
            
            
            
                        
                        
                        <li class="toc-li-3">
                            <a href="#0-255与相应ascii码转换">0-255与相应ascii码转换</a>
                        </li>
                    
                
            
            
            
                        
                        
                        <li class="toc-li-3">
                            <a href="#进制转换">进制转换</a>
                        </li>
                    
                
            
            
            
                        
                        
                        <li class="toc-li-3">
                            <a href="#类相关">类相关</a>
                        </li>
                    
                
            
            
            
                        
                        
                        <li class="toc-li-3">
                            <a href="#变量相关">变量相关</a>
                        </li>
                    
                
            
            
            
                        
                        
                        <li class="toc-li-2">
                            <a href="#内建函数简介">内建函数简介</a>
                        </li>
                    
                
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            
            </ul>
</div>
  <div tabindex="-1" id="notebook" class="border-box-sizing">
    <div class="container" id="notebook-container">

<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="built-in-function">built-in function<a class="anchor-link" href="#built-in-function">&#182;</a></h2>
</div>
</div>
</div>
<div class="cell border-box-sizing code_cell rendered">
<div class="input">
<div class="prompt input_prompt">In&nbsp;[1]:</div>
<div class="inner_cell">
    <div class="input_area">
<div class=" highlight hl-ipython3"><pre><span></span><span class="nb">dir</span><span class="p">(</span><span class="n">__builtins__</span><span class="p">)</span>
</pre></div>

</div>
</div>
</div>

<div class="output_wrapper">
<div class="output">


<div class="output_area">

<div class="prompt output_prompt">Out[1]:</div>




<div class="output_text output_subarea output_execute_result">
<pre>[&#39;ArithmeticError&#39;,
 &#39;AssertionError&#39;,
 &#39;AttributeError&#39;,
 &#39;BaseException&#39;,
 &#39;BlockingIOError&#39;,
 &#39;BrokenPipeError&#39;,
 &#39;BufferError&#39;,
 &#39;BytesWarning&#39;,
 &#39;ChildProcessError&#39;,
 &#39;ConnectionAbortedError&#39;,
 &#39;ConnectionError&#39;,
 &#39;ConnectionRefusedError&#39;,
 &#39;ConnectionResetError&#39;,
 &#39;DeprecationWarning&#39;,
 &#39;EOFError&#39;,
 &#39;Ellipsis&#39;,
 &#39;EnvironmentError&#39;,
 &#39;Exception&#39;,
 &#39;False&#39;,
 &#39;FileExistsError&#39;,
 &#39;FileNotFoundError&#39;,
 &#39;FloatingPointError&#39;,
 &#39;FutureWarning&#39;,
 &#39;GeneratorExit&#39;,
 &#39;IOError&#39;,
 &#39;ImportError&#39;,
 &#39;ImportWarning&#39;,
 &#39;IndentationError&#39;,
 &#39;IndexError&#39;,
 &#39;InterruptedError&#39;,
 &#39;IsADirectoryError&#39;,
 &#39;KeyError&#39;,
 &#39;KeyboardInterrupt&#39;,
 &#39;LookupError&#39;,
 &#39;MemoryError&#39;,
 &#39;NameError&#39;,
 &#39;None&#39;,
 &#39;NotADirectoryError&#39;,
 &#39;NotImplemented&#39;,
 &#39;NotImplementedError&#39;,
 &#39;OSError&#39;,
 &#39;OverflowError&#39;,
 &#39;PendingDeprecationWarning&#39;,
 &#39;PermissionError&#39;,
 &#39;ProcessLookupError&#39;,
 &#39;RecursionError&#39;,
 &#39;ReferenceError&#39;,
 &#39;ResourceWarning&#39;,
 &#39;RuntimeError&#39;,
 &#39;RuntimeWarning&#39;,
 &#39;StopAsyncIteration&#39;,
 &#39;StopIteration&#39;,
 &#39;SyntaxError&#39;,
 &#39;SyntaxWarning&#39;,
 &#39;SystemError&#39;,
 &#39;SystemExit&#39;,
 &#39;TabError&#39;,
 &#39;TimeoutError&#39;,
 &#39;True&#39;,
 &#39;TypeError&#39;,
 &#39;UnboundLocalError&#39;,
 &#39;UnicodeDecodeError&#39;,
 &#39;UnicodeEncodeError&#39;,
 &#39;UnicodeError&#39;,
 &#39;UnicodeTranslateError&#39;,
 &#39;UnicodeWarning&#39;,
 &#39;UserWarning&#39;,
 &#39;ValueError&#39;,
 &#39;Warning&#39;,
 &#39;ZeroDivisionError&#39;,
 &#39;__IPYTHON__&#39;,
 &#39;__build_class__&#39;,
 &#39;__debug__&#39;,
 &#39;__doc__&#39;,
 &#39;__import__&#39;,
 &#39;__loader__&#39;,
 &#39;__name__&#39;,
 &#39;__package__&#39;,
 &#39;__spec__&#39;,
 &#39;abs&#39;,
 &#39;all&#39;,
 &#39;any&#39;,
 &#39;ascii&#39;,
 &#39;bin&#39;,
 &#39;bool&#39;,
 &#39;bytearray&#39;,
 &#39;bytes&#39;,
 &#39;callable&#39;,
 &#39;chr&#39;,
 &#39;classmethod&#39;,
 &#39;compile&#39;,
 &#39;complex&#39;,
 &#39;copyright&#39;,
 &#39;credits&#39;,
 &#39;delattr&#39;,
 &#39;dict&#39;,
 &#39;dir&#39;,
 &#39;display&#39;,
 &#39;divmod&#39;,
 &#39;enumerate&#39;,
 &#39;eval&#39;,
 &#39;exec&#39;,
 &#39;filter&#39;,
 &#39;float&#39;,
 &#39;format&#39;,
 &#39;frozenset&#39;,
 &#39;get_ipython&#39;,
 &#39;getattr&#39;,
 &#39;globals&#39;,
 &#39;hasattr&#39;,
 &#39;hash&#39;,
 &#39;help&#39;,
 &#39;hex&#39;,
 &#39;id&#39;,
 &#39;input&#39;,
 &#39;int&#39;,
 &#39;isinstance&#39;,
 &#39;issubclass&#39;,
 &#39;iter&#39;,
 &#39;len&#39;,
 &#39;license&#39;,
 &#39;list&#39;,
 &#39;locals&#39;,
 &#39;map&#39;,
 &#39;max&#39;,
 &#39;memoryview&#39;,
 &#39;min&#39;,
 &#39;next&#39;,
 &#39;object&#39;,
 &#39;oct&#39;,
 &#39;open&#39;,
 &#39;ord&#39;,
 &#39;pow&#39;,
 &#39;print&#39;,
 &#39;property&#39;,
 &#39;range&#39;,
 &#39;repr&#39;,
 &#39;reversed&#39;,
 &#39;round&#39;,
 &#39;set&#39;,
 &#39;setattr&#39;,
 &#39;slice&#39;,
 &#39;sorted&#39;,
 &#39;staticmethod&#39;,
 &#39;str&#39;,
 &#39;sum&#39;,
 &#39;super&#39;,
 &#39;tuple&#39;,
 &#39;type&#39;,
 &#39;vars&#39;,
 &#39;zip&#39;]</pre>
</div>

</div>

</div>
</div>

</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="&#24120;&#29992;&#20869;&#24314;&#20989;&#25968;">&#24120;&#29992;&#20869;&#24314;&#20989;&#25968;<a class="anchor-link" href="#&#24120;&#29992;&#20869;&#24314;&#20989;&#25968;">&#182;</a></h3>
<pre><code>['dir', 'format', 'help', 'id', 'input', 'open', 'print', 'quit', 'range', 'type', 'input', 'zip']</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="&#25968;&#23398;&#30456;&#20851;">&#25968;&#23398;&#30456;&#20851;<a class="anchor-link" href="#&#25968;&#23398;&#30456;&#20851;">&#182;</a></h3>
<pre><code>['abs', 'len', 'max', 'min', 'pow', 'round', 'reversed', 'sorted', 'sum', 'divmod']</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="&#25968;&#25454;&#31867;&#22411;">&#25968;&#25454;&#31867;&#22411;<a class="anchor-link" href="#&#25968;&#25454;&#31867;&#22411;">&#182;</a></h3>
<pre><code>['bool', 'complex', 'dict', 'list', 'str', 'int', 'float', 'tuple', 'set', 'iter']</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="&#20989;&#25968;&#24335;&#32534;&#31243;">&#20989;&#25968;&#24335;&#32534;&#31243;<a class="anchor-link" href="#&#20989;&#25968;&#24335;&#32534;&#31243;">&#182;</a></h3>
<pre><code>['filter', 'map']</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="0-255&#19982;&#30456;&#24212;ascii&#30721;&#36716;&#25442;">0-255&#19982;&#30456;&#24212;ascii&#30721;&#36716;&#25442;<a class="anchor-link" href="#0-255&#19982;&#30456;&#24212;ascii&#30721;&#36716;&#25442;">&#182;</a></h3>
<pre><code>['chr', 'ord']</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="&#36827;&#21046;&#36716;&#25442;">&#36827;&#21046;&#36716;&#25442;<a class="anchor-link" href="#&#36827;&#21046;&#36716;&#25442;">&#182;</a></h3>
<pre><code>['bin', 'hex', 'oct']</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="&#31867;&#30456;&#20851;">&#31867;&#30456;&#20851;<a class="anchor-link" href="#&#31867;&#30456;&#20851;">&#182;</a></h3>
<pre><code>['callable', 'classmethod', 'delattr', 'getattr', 'hasattr', 'issubclass', 'isinstance', 'setattr', 'staticmethod', 'super']</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h3 id="&#21464;&#37327;&#30456;&#20851;">&#21464;&#37327;&#30456;&#20851;<a class="anchor-link" href="#&#21464;&#37327;&#30456;&#20851;">&#182;</a></h3>
<pre><code>['globals', 'locals', 'vars']</code></pre>

</div>
</div>
</div>
<div class="cell border-box-sizing text_cell rendered"><div class="prompt input_prompt">
</div>
<div class="inner_cell">
<div class="text_cell_render border-box-sizing rendered_html">
<h2 id="&#20869;&#24314;&#20989;&#25968;&#31616;&#20171;">&#20869;&#24314;&#20989;&#25968;&#31616;&#20171;<a class="anchor-link" href="#&#20869;&#24314;&#20989;&#25968;&#31616;&#20171;">&#182;</a></h2><table>
<thead><tr>
<th style="text-align:center">函数</th>
<th style="text-align:center">简介</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align:center">abs()</td>
<td style="text-align:center">　　获取绝对值</td>
</tr>
<tr>
<td style="text-align:center">all()</td>
<td style="text-align:center">　　接受一个迭代器，如果迭代器的所有元素都为真，那么返回True，否则返回False</td>
</tr>
<tr>
<td style="text-align:center">any()</td>
<td style="text-align:center">　　接受一个迭代器，如果迭代器里有一个元素为真，那么返回True,否则返回False</td>
</tr>
<tr>
<td style="text-align:center">ascii()</td>
<td style="text-align:center">　　调用对象的<strong>repr</strong>()方法，获得该方法的返回值.</td>
</tr>
<tr>
<td style="text-align:center">bin()</td>
<td style="text-align:center">　将十进制数分别转换为2进制</td>
</tr>
<tr>
<td style="text-align:center">oct()</td>
<td style="text-align:center">将十进制数分别转换为8进制</td>
</tr>
<tr>
<td style="text-align:center">hex()</td>
<td style="text-align:center">　将十进制数分别转换为16进制。</td>
</tr>
<tr>
<td style="text-align:center">bool()</td>
<td style="text-align:center">　　测试一个对象是True还是False.</td>
</tr>
<tr>
<td style="text-align:center">bytes()</td>
<td style="text-align:center">　　将一个字符串转换成字节类型</td>
</tr>
<tr>
<td style="text-align:center">str()</td>
<td style="text-align:center">　　将字符类型/数值类型等转换为字符串类型</td>
</tr>
<tr>
<td style="text-align:center">challable()</td>
<td style="text-align:center">　　判断对象是否可以被调用，能被调用的对象就是一个callables对象，比如函数和带有<strong>call</strong>()的实例</td>
</tr>
<tr>
<td style="text-align:center">char()</td>
</tr>
<tr>
<td style="text-align:center">ord()</td>
<td style="text-align:center">　　查看十进制数对应的ASCII字符/查看某个ASCII对应的十进制数</td>
</tr>
<tr>
<td style="text-align:center">classmethod()</td>
<td style="text-align:center">　　用来指定一个方法为类的方法，由类直接调用执行，只有一个cls参数,执行雷的方法时，自动将调用该方法的类赋值给cls.没有此参数指定的类的方法为实例方法</td>
</tr>
<tr>
<td style="text-align:center">complie()</td>
<td style="text-align:center">　　将字符串编译成python能识别或可以执行的代码，也可以将文字读成字符串再编译</td>
</tr>
<tr>
<td style="text-align:center">complex()</td>
</tr>
<tr>
<td style="text-align:center">delattr()</td>
<td style="text-align:center">　　删除对象的属性</td>
</tr>
<tr>
<td style="text-align:center">dict()</td>
<td style="text-align:center">　　创建数据字典</td>
</tr>
<tr>
<td style="text-align:center">dir()</td>
<td style="text-align:center">　　不带参数时返回当前范围内的变量，方法和定义的类型列表，带参数时返回参数的属性，方法列表</td>
</tr>
<tr>
<td style="text-align:center">divmod()</td>
<td style="text-align:center">　　分别取商和余数</td>
</tr>
<tr>
<td style="text-align:center">enumerate()</td>
<td style="text-align:center">　　返回一个可以枚举的对象，该对象的next()方法将返回一个元组</td>
</tr>
<tr>
<td style="text-align:center">eval()</td>
<td style="text-align:center">　　将字符串str当成有效的表达式来求值并返回计算结果</td>
</tr>
<tr>
<td style="text-align:center">exec()</td>
<td style="text-align:center">　　执行字符串或complie方法编译过的字符串，没有返回值</td>
</tr>
<tr>
<td style="text-align:center">filter()</td>
<td style="text-align:center">　　过滤器，构造一个序列，等价于[ item for item in iterables if function(item)]，在函数中设定过滤条件，逐一循环迭代器中的元素，将返回值为True时的元素留下，形成一个filter类型数据</td>
</tr>
<tr>
<td style="text-align:center">float()</td>
<td style="text-align:center">　　讲一个字符串或整数转换为浮点数</td>
</tr>
<tr>
<td style="text-align:center">format()</td>
<td style="text-align:center">　　格式化输出字符串</td>
</tr>
<tr>
<td style="text-align:center">frozenset()</td>
<td style="text-align:center">　　创建一个不可修改的集合</td>
</tr>
<tr>
<td style="text-align:center">getattr()</td>
<td style="text-align:center">　　获取对象的属性</td>
</tr>
<tr>
<td style="text-align:center">globals()</td>
<td style="text-align:center">　　返回一个描述当前全局变量的字典</td>
</tr>
<tr>
<td style="text-align:center">hasattr()</td>
<td style="text-align:center">判断对象object是否包含名为name的特性（hasattr是通过调用getattr(object，name)）是否抛出异常来实现的。</td>
</tr>
<tr>
<td style="text-align:center">hash()</td>
<td style="text-align:center">　　哈希值</td>
</tr>
<tr>
<td style="text-align:center">help()</td>
<td style="text-align:center">　　返回对象的帮助文档</td>
</tr>
<tr>
<td style="text-align:center">id()</td>
<td style="text-align:center">　　返回对象的内存地址</td>
</tr>
<tr>
<td style="text-align:center">input()</td>
<td style="text-align:center">　　获取用户输入内容</td>
</tr>
<tr>
<td style="text-align:center">int()</td>
<td style="text-align:center">　　将一个字符串或数值转换为一个普通整数</td>
</tr>
<tr>
<td style="text-align:center">isinstance()</td>
<td style="text-align:center">　　检查对象是否是类的对象，返回True或False</td>
</tr>
<tr>
<td style="text-align:center">issubclass()</td>
<td style="text-align:center">　　检查一个类是否是另一个类的子类。返回True或False</td>
</tr>
<tr>
<td style="text-align:center">iter()</td>
<td style="text-align:center">返回一个iterator对象</td>
</tr>
<tr>
<td style="text-align:center">len()</td>
<td style="text-align:center">　　返回对象长度</td>
</tr>
<tr>
<td style="text-align:center">list()</td>
<td style="text-align:center">　　列表构造函数</td>
</tr>
<tr>
<td style="text-align:center">locals()</td>
<td style="text-align:center">　　打印当前可用的局部变量的字典</td>
</tr>
<tr>
<td style="text-align:center">map(</td>
<td style="text-align:center">function, iterable,...) 对于参数iterable中的每个元素都应用fuction函数，并将结果作为列表返回。</td>
</tr>
<tr>
<td style="text-align:center">max()</td>
<td style="text-align:center">　　返回给定元素里最大值</td>
</tr>
<tr>
<td style="text-align:center">min()</td>
<td style="text-align:center">　　返回给定元素里最小值</td>
</tr>
<tr>
<td style="text-align:center">next()</td>
<td style="text-align:center">　　返回一个可迭代数据结构（如列表）中的下一项</td>
</tr>
<tr>
<td style="text-align:center">object()</td>
<td style="text-align:center">获取一个新的，无特性(geatureless)对象。Object是所有类的基类。它提供的方法将在所有的类型实例中共享。</td>
</tr>
<tr>
<td style="text-align:center">open()</td>
<td style="text-align:center">　　打开文件</td>
</tr>
<tr>
<td style="text-align:center">pow()</td>
<td style="text-align:center">　　幂函数</td>
</tr>
<tr>
<td style="text-align:center">property()</td>
</tr>
<tr>
<td style="text-align:center">range()</td>
<td style="text-align:center">　　根据需要生成一个指定范围的数字，可以提供你需要的控制来迭代指定的次数</td>
</tr>
<tr>
<td style="text-align:center">repr()</td>
<td style="text-align:center">　　将任意值转换为字符串，供计时器读取的形式</td>
</tr>
<tr>
<td style="text-align:center">reversed()</td>
<td style="text-align:center">　　　反转，逆序对象</td>
</tr>
<tr>
<td style="text-align:center">round()</td>
<td style="text-align:center">　　四舍五入</td>
</tr>
<tr>
<td style="text-align:center">set()</td>
<td style="text-align:center">集合构造函数</td>
</tr>
<tr>
<td style="text-align:center">setattr()</td>
<td style="text-align:center">　　与getattr()相对应</td>
</tr>
<tr>
<td style="text-align:center">slice()</td>
<td style="text-align:center">　　切片功能</td>
</tr>
<tr>
<td style="text-align:center">sorted()</td>
<td style="text-align:center">　　排序</td>
</tr>
<tr>
<td style="text-align:center">staticmethod()</td>
</tr>
<tr>
<td style="text-align:center">str()</td>
<td style="text-align:center">　　字符串构造函数</td>
</tr>
<tr>
<td style="text-align:center">sum()</td>
<td style="text-align:center">　　求和</td>
</tr>
<tr>
<td style="text-align:center">super()</td>
<td style="text-align:center">　　调用父类的方法</td>
</tr>
<tr>
<td style="text-align:center">tuple()</td>
<td style="text-align:center">　　元组构造函数</td>
</tr>
<tr>
<td style="text-align:center">type()</td>
<td style="text-align:center">　　显示对象所属的类型</td>
</tr>
<tr>
<td style="text-align:center">vars()</td>
<td style="text-align:center">　　返回 <code>__dict__</code> 属性, 比如模块, 类, 实例, 或者其他 带有 <code>__dict__</code> 属性的 object</td>
</tr>
<tr>
<td style="text-align:center">zip()</td>
<td style="text-align:center">　　将对象逐一配对</td>
</tr>
</tbody>
</table>

</div>
</div>
</div>
    </div>
  </div>
</body>

 


</html>
